//https://www.nowcoder.com/practice/b1f7a77416194fd3abd63737cdfcf82b?tpId=69&tqId=29669&rp=1&ru=/activity/oj&qru=/ta/hust-kaoyan/question-ranking
//描述
//给出年分m和一年中的第n天，算出第n天是几月几号。
//输入描述：
//输入包括两个整数y(1<=y<=3000)，n(1<=n<=366)。
//输出描述：
//可能有多组测试数据，对于每组数据， 按 yyyy-mm-dd的格式将输入中对应的日期打印出来。
#include <iostream>
using namespace std;

class Date
{
public:
    Date(int year, int month, int day)
        :_year(year)
        ,_month(month)
        ,_day(day)
    {}

    int GetMonthDay()
    {
        static const int monthDay[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        if(_month == 2)
        {
            if(_year % 400 == 0 || (_year % 4 == 0 && _year % 100 != 0))
            return 29;
            else
            return 28;
        }
        else
        return monthDay[_month];
    }

    void Print()
    {
        cout << _year / 1000 << (_year / 100) % 10 << (_year / 10) % 10 << _year % 10;
        cout << "-" << _month / 10 << _month % 10;
        cout << "-" << _day / 10 << _day % 10 << endl;
    }

    Date& operator+=(int gap)
    {
        gap += _day;
        while(gap > GetMonthDay())
        {
            gap -= GetMonthDay();
            _month++;
            if(_month == 13)
            {
                _month = 1;
                _year++;
            }
        }
        _day = gap;
        return (*this);
    }

private:
    int _year;
    int _month;
    int _day;
};

int main() {
    int year, day;
    while(cin >> year >> day)
    {
        Date d(year, 1, 0);
        d += day;
        d.Print();
    }
    return 0;
}